/**
 * 配置常量
 */
// API 基础路径
global.API_BASE_PATH = process.env.API_BASE_PATH
// token 存储加密
global.TOKEN_ENCRYPT_ENABLE = process.env.TOKEN_ENCRYPT_ENABLE

// 登录接口
global.LOGIN_URI = '/user/login'
// 刷新token地址
global.REFRESH_TOKEN_URI = '/user/token/refresh'
global.APP_NAME = 'STONE'
global.APP_TITLE = '陨石科技'
global.DEFAULT_AVATAR = '/static/images/common/default-avatar.png'
global.PAGE_SIZE = 20


// 浏览器识别
var ua = navigator.userAgent.toLowerCase()
global.Browser = {
  isWechat: /micromessenger/.test(ua),
  isAlipay: /alipayclient/.test(ua),
  isCrawler: /author\/crawler/.test(ua)
}

/**
 * 设置浏览器标题
 * @param title
 */
global.setDocumentTitle = function (title) {
  title = title || global.APP_TITLE
  document.title = title
  if (/ip(hone|od|ad)/i.test(navigator.userAgent)) {
    setTimeout(function () {
      var iframe = document.createElement('iframe')
      iframe.src = '/MP_verify_dbtLjvj0pndDlxpP.txt'
      iframe.style.display = 'none'
      iframe.onload = function () {
        setTimeout(function () {
          iframe.remove()
        }, 0)
        document.body.appendChild(iframe)
      }
    }, 0)
  }
}

/**
 * 设置窗体配置
 */
global.setWin = function () {
  var winWidth = window.innerWidth
  var winHeight = window.innerHeight
  let fontSize = winWidth / 375 * 20
  document.getElementsByTagName('html')[0].style.fontSize = fontSize + 'px'
  // 窗体
  global.$win = {
    screenRatio: winHeight / winWidth,
    rem: fontSize,
    width: winWidth,
    height: winHeight,
    widthRem: winWidth / fontSize,
    heightRem: winHeight / fontSize
  }
}

export {}
